/*

package cloud.xlh.my_system.shiro.realm;

import cloud.xlh.my_system.mapper.login.custom.UserMapper;
import cloud.xlh.my_system.pojo.User;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;


*/
/**
 * Created with IntelliJ IDEA.
 *
 * @ project name : xlh_osms
 * @ Author: XuLeHuang
 * @ Date: 2022/6/26 17:11
 * @ Description:
 *//*


@Configuration
public class MyRealm extends AuthorizingRealm {
    @Autowired
    private UserMapper userMapper;

    */
/**
     * 根据用户角色授权
     *//*


    @Override
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
        return null;
    }


    */
/**
     * 验证账号密码
     *
     * @param token
     * @return
     * @throws AuthenticationException
     *//*


    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
        String userName = (String) token.getPrincipal();
        if (userName == null) {
            return null;
        }
        //从数据库获取用户信息
        User dbUser = userMapper.findByUsername(userName);
        if (dbUser == null) {
            return null;
        }
        SecurityUtils.getSubject().getSession().setAttribute("user", dbUser);
        // 验证账号密码
        SimpleAuthenticationInfo authorizationInfo =
                new SimpleAuthenticationInfo(dbUser.getName(), dbUser.getPassword(),
                        dbUser.getName());
        return authorizationInfo;
    }
}


*/
